package algs.days.day11;

import edu.princeton.cs.algs4.StdOut;
import edu.princeton.cs.algs4.Stopwatch;



/**
 * 
 * Output:

0.00000	1	1	Special
0.00000	1	3	Special
0.00000	1	7	Special
0.00000	2	15	
0.00000	1	31	Special
0.00000	3	63	
0.00000	1	127	Special
0.00000	4	255	
0.00000	2	511	
0.00000	4	1023	
0.00000	2	2047	
0.00000	12	4095	
0.00000	1	8191	Special
0.00000	4	16383	
0.00000	4	32767	
0.00000	8	65535	
0.00000	1	131071	Special
0.00000	16	262143	
0.00000	1	524287	Special
0.00000	24	1048575	
0.00000	6	2097151	
0.00000	8	4194303	
0.00000	2	8388607	
0.00000	48	16777215	
0.00000	4	33554431	
0.00000	4	67108863	
0.00000	4	134217727	
0.00000	32	268435455	
0.00000	4	536870911	
0.00000	48	1073741823	
0.00000	1	2147483647	Special
0.00000	16	4294967295	
0.00000	8	8589934591	
0.00000	4	17179869183	
0.00000	8	34359738367	
0.00000	256	68719476735	
0.01600	2	137438953471	
0.00000	4	274877906943	
0.01500	8	549755813887	
0.00000	96	1099511627775	
0.01600	2	2199023255551	
0.03100	72	4398046511103	
0.03100	4	8796093022207	
0.04700	64	17592186044415	
0.06300	32	35184372088831	
0.07800	8	70368744177663	
0.12400	4	140737488355327	
0.17200	384	281474976710655	
0.23400	2	562949953421311	
0.31200	64	1125899906842623	
0.42200	16	2251799813685247	
0.59300	64	4503599627370495	
0.87500	4	9007199254740991	
1.20100	80	18014398509481983	
1.79500	32	36028797018963967	
2.43400	128	72057594037927935	
3.37200	8	144115188075855871	
4.85500	32	288230376151711743	
6.80300	2	576460752303423487	
9.51700	2304	1152921504606846975	
13.51200	1	2305843009213693951	Special
19.51900	4	4611686018427387903	


 */
public class AnotherTimingBehavior {
	
	// what does this function do?
	static long process(long n) {
		long m = (long)Math.sqrt(n);
		int ct = 1;
		while (m > 1) {
			if (n % m-- == 0) { ct++; }
		}
		return ct;
	}
	
	
	public static void main(String[] args) {
		long n = 2;
		while (n > 1) {
			Stopwatch sw = new Stopwatch();
			long c = process(n-1);
			double elapse = sw.elapsedTime();
			String special = ""; 
			if (c == 1) { special = "Special"; }
			StdOut.printf("%.5f\t%d\t%d\t%s\n", elapse, c, (n-1),special);
			n *= 2;
		}
	}
}
